const path = require('path');
const { base, senior, options } = require('./public');
const { merge } = require('webpack-merge');
const {port} = require('../config/index')
const entry = {
  index: {
    import: path.resolve(__dirname, '../src/basic/index.ts'),
    library: {
      name: 'inbizPluginInterface["basic"]',
      type: 'assign-properties',
    }
  }
}

if (options.isBuild) {
  entry.locale =  {
    import: path.resolve(__dirname, '../src/basic/locale.ts'),
    library: {
      type: 'commonjs',
      export: 'default'
    }
  }
}

module.exports = merge(base, {
  entry,
  output: {
    filename: '[name].js',
    path: path.resolve(__dirname, '../dist/basic'),
    chunkLoadingGlobal: `base_${Date.now()}_${Math.random()
      .toString()
      .slice(2)}`,
  },
  devServer: {
    port: port.basic,
  },
  externals: senior,
  resolve: {
    alias: {
      '@assets': path.resolve(__dirname, '../src/assets'),
    },
  },
});
